package o2o.dao.PO.company.postman;

import lombok.Data;
import lombok.experimental.Accessors;
import o2o.cache.company.postman.PostCompanyMemory;
import o2o.cache.shop.ShopMemory;
import o2o.company.model.ShopInfo;
import o2o.dao.VO.company.postman.ShopSignCompanyInfoVO;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 商家签约配送公司信息
 *
 * @User: @Created by yangtk
 * @Date: @Date 2019/8/7 9:20
 * @Classname: ShopSignCompanyInfo
 * @To change this template use File | Settings | File Templates.
 */
@Data
@Accessors(chain = true)
public class ShopSignCompanyInfo implements Serializable {

    private Long id;
    private String sysAppKey;
    private Long companyId;
    private Long shopId;
    private Long applyTime;
    private Long dealTime;
    private int status;
    private Double money;
    private Double companyShareRate;    //  配送公司分成比例
    private String refuseReason;
    private Date lastAccountDate;       // 最近一次结算时间
    private String note;

    private int delFlag;
    private String createUser;
    private long createTime;
    private String updateUser;
    private long updateTime;

    public ShopSignCompanyInfoVO convert2VO() {
        ShopSignCompanyInfoVO infoVO = new ShopSignCompanyInfoVO();
        BeanUtils.copyProperties(this, infoVO);
        ShopInfo shopInfo = ShopMemory.getInstance().getShopById(this.getShopId());
        if (shopInfo != null) {
            infoVO.setShopAddress(shopInfo.getAddress()).setShopName(shopInfo.getShopName())
                    .setShopOwnUsername(shopInfo.getOwnUsername())
                    .setShopOwnName(shopInfo.getOwnName())
                    .setShopPhone(shopInfo.getTelephone())
                    .setShopIsOpen(shopInfo.getIsOpen());
        }
        PostCompanyInfo postCompanyInfo = PostCompanyMemory.getInstance().getById(companyId);
        if (postCompanyInfo != null) {
            infoVO.setPostCompanyName(postCompanyInfo.getCompanyName()).setPostCompanyAddress(postCompanyInfo.getAddress());
        }
        return infoVO;
    }

}
